import 'package:xinxuan/vo/common_vo/common_address_item_vo.dart';

class OrderDetailVo {

  OrderDetailData? data;

  OrderDetailVo({this.data});

  OrderDetailVo.fromJson(Map<String, dynamic> json) {
    data = json['data'] != null ? new OrderDetailData.fromJson(json['data']) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.data != null) {
      data['data'] = this.data!.toJson();
    }
    return data;
  }
}

class OrderDetailData {
  int? id;
  int? type;
  String? orderSn;
  int? userId;
  int? status;
  int? paymentType;
  int? payStatus;
  String? totalAmount;
  String? createdAt;
  String? updatedAt;
  String? paidAt;
  String? deletedAt;
  String? payAmount;
  String? payableAmount;
  int? isStar;
  String? gratitude;
  List<OrderProductsItem>? products;
  CommonAddressItem? address;

  OrderDetailData(
      {this.id,
      this.type,
      this.orderSn,
      this.userId,
      this.status,
      this.paymentType,
      this.payStatus,
      this.createdAt,
      this.updatedAt,
      this.paidAt,
      this.deletedAt,
      this.payAmount,
      this.totalAmount,
      this.payableAmount,
      this.products,
      this.address,
      this.isStar,
      this.gratitude});

  OrderDetailData.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    type = json['type'];
    orderSn = json['order_sn'];
    userId = json['user_id'];
    status = json['status'];
    paymentType = json['payment_type'];
    payStatus = json['pay_status'];
    createdAt = json['created_at'];
    updatedAt = json['updated_at'];
    paidAt = json['paid_at'];
    deletedAt = json['deleted_at'];
    payAmount = json['pay_amount'];
    payableAmount = json['payable_amount'];
    totalAmount = json['total_amount'];
    isStar = json['is_star'];
    gratitude = json['gratitude'];
    if (json['products'] != null) {
      products = [];
      json['products'].forEach((v) {
        products!.add(new OrderProductsItem.fromJson(v));
      });
    }
    address =
        json['address'] != null ? new CommonAddressItem.fromJson(json['address']) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['type'] = this.type;
    data['order_sn'] = this.orderSn;
    data['user_id'] = this.userId;
    data['status'] = this.status;
    data['payment_type'] = this.paymentType;
    data['pay_status'] = this.payStatus;
    data['created_at'] = this.createdAt;
    data['updated_at'] = this.updatedAt;
    data['paid_at'] = this.paidAt;
    data['deleted_at'] = this.deletedAt;
    data['pay_amount'] = this.payAmount;
    data['total_amount'] = this.totalAmount;
    data['payable_amount'] = this.payableAmount;
    data['is_star'] = this.isStar;
    data['gratitude'] = this.gratitude;
    if (this.products != null) {
      data['products'] = this.products!.map((v) => v.toJson()).toList();
    }
    if (this.address != null) {
      data['address'] = this.address!.toJson();
    }
    return data;
  }
}

class OrderProductsItem {
  int? id;
  int? orderId;
  int? productId;
  String? title;
  String? image;
  String? price;
  int? quantity;
  int? skuId;
  String? specIds;
  String? specStr;

  OrderProductsItem(
      {this.id,
      this.orderId,
      this.productId,
      this.title,
      this.image,
      this.price,
      this.quantity,
      this.skuId,
      this.specIds,
      this.specStr});

  OrderProductsItem.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    orderId = json['order_id'];
    productId = json['product_id'];
    title = json['title'];
    image = json['image'];
    price = json['price'];
    quantity = json['quantity'];
    skuId = json['sku_id'];
    specIds = json['spec_ids'];
    specStr = json['spec_str'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['order_id'] = this.orderId;
    data['product_id'] = this.productId;
    data['title'] = this.title;
    data['image'] = this.image;
    data['price'] = this.price;
    data['quantity'] = this.quantity;
    data['sku_id'] = this.skuId;
    data['spec_ids'] = this.specIds;
    data['spec_str'] = this.specStr;
    return data;
  }
}
